

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>AG_fft_tools Package &mdash; agpy 0.1.2 documentation</title>
    
    <link rel="stylesheet" href="_static/extra.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '0.1.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="agpy 0.1.2 documentation" href="index.html" />
    <link rel="next" title="plfit Package" href="plfit.html" />
    <link rel="prev" title="Image Tools" href="image_tools.html" />
     
    <script type="text/javascript">

      var _gaq = _gaq || [];
      _gaq.push(['_setDomainName', 'pyspeckit.bitbucket.org']);
      _gaq.push(['_setAllowHash', false]);
      _gaq.push(['_trackPageview']);


    </script>
    <link rel="stylesheet" type="text/css" href="_static/extra.css" />
  </head>
  <body>
    <div class="header-wrapper">
      <div class="header">
        <h1><a href="index.html">agpy 0.1.2 documentation</a></h1>
        <div class="rel">
          <a href="http://agpy.googlecode.com">agpy Home </a>  |
          <a href=index.html>Docs Home </a>  |
          <a href="http://code.google.com/p/agpy/w/list">Wiki</a>  |
          <a href=search.html>Search </a>
        </div>
       </div>
    </div>

    <div class="content-wrapper">
      <div class="content">
        <div class="document">
            
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="ag-fft-tools-package">
<h1>AG_fft_tools Package<a class="headerlink" href="#ag-fft-tools-package" title="Permalink to this headline">¶</a></h1>
<div class="section" id="id1">
<h2><a class="reference internal" href="#module-AG_fft_tools" title="AG_fft_tools"><tt class="xref py py-mod docutils literal"><span class="pre">AG_fft_tools</span></tt></a> Package<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h2>
<span class="target" id="module-AG_fft_tools"></span><p>Wrappers around numpy, scipy, and pyfftw tools to perform 2D convolution in
general, smoothing with a set of &#8216;standard&#8217; kernels, and computing power
spectra and PSDs.</p>
</div>
<div class="section" id="convolve-nd-module">
<h2><tt class="xref py py-mod docutils literal"><span class="pre">convolve_nd</span></tt> Module<a class="headerlink" href="#convolve-nd-module" title="Permalink to this headline">¶</a></h2>
<span class="target" id="module-AG_fft_tools.convolve_nd"></span><dl class="function">
<dt id="AG_fft_tools.convolve_nd.convolvend">
<tt class="descclassname">AG_fft_tools.convolve_nd.</tt><tt class="descname">convolvend</tt><big>(</big><em>array</em>, <em>kernel</em>, <em>boundary='fill'</em>, <em>fill_value=0</em>, <em>crop=True</em>, <em>return_fft=False</em>, <em>fftshift=True</em>, <em>fft_pad=True</em>, <em>psf_pad=False</em>, <em>interpolate_nan=False</em>, <em>quiet=False</em>, <em>ignore_edge_zeros=False</em>, <em>min_wt=0.0</em>, <em>normalize_kernel=False</em>, <em>use_numpy_fft=False</em>, <em>nthreads=1</em><big>)</big><a class="reference internal" href="_modules/AG_fft_tools/convolve_nd.html#convolvend"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#AG_fft_tools.convolve_nd.convolvend" title="Permalink to this definition">¶</a></dt>
<dd><p>Convolve an ndarray with an nd-kernel.  Returns a convolved image with shape =
array.shape.  Assumes image &amp; kernel are centered.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters :</th><td class="field-body"><p class="first"><strong>array: `numpy.ndarray`</strong> :</p>
<blockquote>
<div><p>Array to be convolved with <em>kernel</em></p>
</div></blockquote>
<p><strong>kernel: `numpy.ndarray`</strong> :</p>
<blockquote>
<div><p>Will be normalized if <em>normalize_kernel</em> is set.  Assumed to be
centered (i.e., shifts may result if your kernel is asymmetric)</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns :</th><td class="field-body"><p class="first"><strong>default: `array` convolved with `kernel`</strong> :</p>
<p><strong>if return_fft: fft(`array`) * fft(`kernel`)</strong> :</p>
<blockquote>
<div><ul class="simple">
<li>if fftshift: Determines whether the fft will be shifted before
returning</li>
</ul>
</div></blockquote>
<p><strong>if not(`crop`)</strong> : Returns the image, but with the fft-padded size</p>
<blockquote class="last">
<div><p>instead of the input size</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Examples</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">convolve_fft</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">3</span><span class="p">],[</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">])</span>
<span class="go">array([ 1.,  4.,  3.])</span>
</pre></div>
</div>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">convolve_fft</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="n">np</span><span class="o">.</span><span class="n">nan</span><span class="p">,</span><span class="mi">3</span><span class="p">],[</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">])</span>
<span class="go">array([ 1.,  4.,  3.])</span>
</pre></div>
</div>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">convolve_fft</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">3</span><span class="p">],[</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">])</span>
<span class="go">array([ 1.,  0.,  3.])</span>
</pre></div>
</div>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">convolve_fft</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">],[</span><span class="mi">1</span><span class="p">])</span>
<span class="go">array([ 1.,  2.,  3.])</span>
</pre></div>
</div>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">convolve_fft</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="n">np</span><span class="o">.</span><span class="n">nan</span><span class="p">,</span><span class="mi">3</span><span class="p">],[</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">],</span> <span class="n">interpolate_nan</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="go">array([ 1.,  0.,  3.])</span>
</pre></div>
</div>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">convolve_fft</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="n">np</span><span class="o">.</span><span class="n">nan</span><span class="p">,</span><span class="mi">3</span><span class="p">],[</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">],</span> <span class="n">interpolate_nan</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">min_wt</span><span class="o">=</span><span class="mf">1e-8</span><span class="p">)</span>
<span class="go">array([ 1.,  nan,  3.])</span>
</pre></div>
</div>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">convolve_fft</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="n">np</span><span class="o">.</span><span class="n">nan</span><span class="p">,</span><span class="mi">3</span><span class="p">],[</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">],</span> <span class="n">interpolate_nan</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="go">array([ 1.,  4.,  3.])</span>
</pre></div>
</div>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">convolve_fft</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="n">np</span><span class="o">.</span><span class="n">nan</span><span class="p">,</span><span class="mi">3</span><span class="p">],[</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">],</span> <span class="n">interpolate_nan</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">normalize_kernel</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="go">array([ 1.,  2.,  3.])</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="AG_fft_tools.convolve_nd.fftwn">
<tt class="descclassname">AG_fft_tools.convolve_nd.</tt><tt class="descname">fftwn</tt><big>(</big><em>array</em>, <em>nthreads=1</em><big>)</big><a class="reference internal" href="_modules/AG_fft_tools/convolve_nd.html#fftwn"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#AG_fft_tools.convolve_nd.fftwn" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="function">
<dt id="AG_fft_tools.convolve_nd.ifftwn">
<tt class="descclassname">AG_fft_tools.convolve_nd.</tt><tt class="descname">ifftwn</tt><big>(</big><em>array</em>, <em>nthreads=1</em><big>)</big><a class="reference internal" href="_modules/AG_fft_tools/convolve_nd.html#ifftwn"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#AG_fft_tools.convolve_nd.ifftwn" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="function">
<dt id="AG_fft_tools.convolve_nd.test_3d">
<tt class="descclassname">AG_fft_tools.convolve_nd.</tt><tt class="descname">test_3d</tt><big>(</big><em>psf_pad</em>, <em>use_numpy_fft</em>, <em>force_ignore_zeros_off</em>, <em>debug=False</em>, <em>tolerance=1.0000000000000001e-17</em><big>)</big><a class="reference internal" href="_modules/AG_fft_tools/convolve_nd.html#test_3d"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#AG_fft_tools.convolve_nd.test_3d" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</div>
<div class="section" id="module-AG_fft_tools.correlate2d">
<span id="correlate2d-module"></span><h2><tt class="xref py py-mod docutils literal"><span class="pre">correlate2d</span></tt> Module<a class="headerlink" href="#module-AG_fft_tools.correlate2d" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="AG_fft_tools.correlate2d.correlate2d">
<tt class="descclassname">AG_fft_tools.correlate2d.</tt><tt class="descname">correlate2d</tt><big>(</big><em>im1</em>, <em>im2</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/AG_fft_tools/correlate2d.html#correlate2d"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#AG_fft_tools.correlate2d.correlate2d" title="Permalink to this definition">¶</a></dt>
<dd><p>Cross-correlation of two images of arbitrary size.  Returns an image
cropped to the largest of each dimension of the input images</p>
<p>Options:
return_fft - if true, return fft(im1)*fft(im2[::-1,::-1]), which is the power</p>
<blockquote>
<div>spectral density</div></blockquote>
<dl class="docutils">
<dt>fftshift - if true, return the shifted psd so that the DC component is in</dt>
<dd>the center of the image</dd>
</dl>
<p>pad - Default on.  Zero-pad image to the nearest 2^n
crop - Default on.  Return an image of the size of the largest input image.</p>
<blockquote>
<div>If the images are asymmetric in opposite directions, will return the largest 
image in both directions.</div></blockquote>
<p>WARNING: Normalization may be arbitrary if you use the PSD</p>
</dd></dl>

</div>
<div class="section" id="module-AG_fft_tools.psds">
<span id="psds-module"></span><h2><tt class="xref py py-mod docutils literal"><span class="pre">psds</span></tt> Module<a class="headerlink" href="#module-AG_fft_tools.psds" title="Permalink to this headline">¶</a></h2>
<p>Power Spectra</p>
<dl class="function">
<dt id="AG_fft_tools.psds.PSD2">
<tt class="descclassname">AG_fft_tools.psds.</tt><tt class="descname">PSD2</tt><big>(</big><em>image</em>, <em>image2=None</em>, <em>oned=False</em>, <em>fft_pad=False</em>, <em>real=False</em>, <em>imag=False</em>, <em>binsize=1.0</em>, <em>radbins=1</em>, <em>azbins=1</em>, <em>radial=False</em>, <em>hanning=False</em>, <em>wavnum_scale=False</em>, <em>twopi_scale=False</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/AG_fft_tools/psds.html#PSD2"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#AG_fft_tools.psds.PSD2" title="Permalink to this definition">¶</a></dt>
<dd><p>Two-dimensional Power Spectral Density.
NAN values are treated as zero.</p>
<dl class="docutils">
<dt>image2 - can specify a second image if you want to see the cross-power-spectrum instead of the </dt>
<dd>power spectrum.</dd>
<dt>oned - return radial profile of 2D PSD (i.e. mean power as a function of spatial frequency)</dt>
<dd>freq,zz = PSD2(image); plot(freq,zz) is a power spectrum</dd>
<dt>fft_pad - Add zeros to the edge of the image before FFTing for a speed</dt>
<dd>boost?  (the edge padding will be removed afterwards)</dd>
</dl>
<p>real - Only compute the real part of the PSD (Default is absolute value)
imag - Only compute the complex part of the PSD (Default is absolute value)
hanning - Multiply the image to be PSD&#8217;d by a 2D Hanning window before performing the FTs.</p>
<blockquote>
<div>Reduces edge effects.  This idea courtesy Paul Ricchiazzia (May 1993), author of the
IDL astrolib psd.pro</div></blockquote>
<p>wavnum_scale - multiply the FFT^2 by the wavenumber when computing the PSD?
twopi_scale - multiply the FFT^2 by 2pi?
azbins - Number of azimuthal (angular) bins to include.  Default is 1, or</p>
<blockquote>
<div>all 360 degrees.  If azbins&gt;1, the data will be split into [azbins]
equally sized pie pieces.  Azbins can also be a numpy array.  See
AG_image_tools.azimuthalAverageBins for details</div></blockquote>
<dl class="docutils">
<dt>radial - An option to return the <em>azimuthal</em> power spectrum (i.e., the spectral power as a function </dt>
<dd>of angle).  Not commonly used.</dd>
</dl>
<p>radbins - number of radial bins (you can compute the azimuthal power spectrum in different annuli)</p>
</dd></dl>

<dl class="function">
<dt id="AG_fft_tools.psds.hanning2d">
<tt class="descclassname">AG_fft_tools.psds.</tt><tt class="descname">hanning2d</tt><big>(</big><em>M</em>, <em>N</em><big>)</big><a class="reference internal" href="_modules/AG_fft_tools/psds.html#hanning2d"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#AG_fft_tools.psds.hanning2d" title="Permalink to this definition">¶</a></dt>
<dd><p>A 2D hanning window, as per IDL&#8217;s hanning function.  See numpy.hanning for the 1d description</p>
</dd></dl>

<dl class="function">
<dt id="AG_fft_tools.psds.power_spectrum">
<tt class="descclassname">AG_fft_tools.psds.</tt><tt class="descname">power_spectrum</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/AG_fft_tools/psds.html#power_spectrum"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#AG_fft_tools.psds.power_spectrum" title="Permalink to this definition">¶</a></dt>
<dd><p>Thin wrapper of PSD2.  Returns the 1D power spectrum in stead of the 2D Power Spectral Density</p>
</dd></dl>

<dl class="function">
<dt id="AG_fft_tools.psds.pspec">
<tt class="descclassname">AG_fft_tools.psds.</tt><tt class="descname">pspec</tt><big>(</big><em>psd2</em>, <em>return_index=True</em>, <em>wavenumber=False</em>, <em>return_stddev=False</em>, <em>azbins=1</em>, <em>binsize=1.0</em>, <em>view=False</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/AG_fft_tools/psds.html#pspec"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#AG_fft_tools.psds.pspec" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a Power Spectrum (radial profile of a PSD) from a Power Spectral Density image</p>
<p>return_index - if true, the first return item will be the indexes
wavenumber - if one dimensional and return_index set, will return a normalized wavenumber instead
view - Plot the PSD (in logspace)?</p>
</dd></dl>

</div>
<div class="section" id="smooth-tools-module">
<h2><tt class="xref py py-mod docutils literal"><span class="pre">smooth_tools</span></tt> Module<a class="headerlink" href="#smooth-tools-module" title="Permalink to this headline">¶</a></h2>
<span class="target" id="module-AG_fft_tools.smooth_tools"></span><dl class="function">
<dt id="AG_fft_tools.smooth_tools.make_kernel">
<tt class="descclassname">AG_fft_tools.smooth_tools.</tt><tt class="descname">make_kernel</tt><big>(</big><em>kernelshape</em>, <em>kernelwidth=3</em>, <em>kerneltype='gaussian'</em>, <em>trapslope=None</em>, <em>normalize_kernel=&lt;function sum at 0x10637bcf8&gt;</em>, <em>force_odd=False</em><big>)</big><a class="headerlink" href="#AG_fft_tools.smooth_tools.make_kernel" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a smoothing kernel for use with <tt class="xref py py-obj docutils literal"><span class="pre">convolve</span></tt> or <tt class="xref py py-obj docutils literal"><span class="pre">convolve_fft</span></tt></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters :</th><td class="field-body"><p class="first"><strong>kernelshape</strong> : n-tuple</p>
<blockquote>
<div><p>A tuple (or list or array) defining the shape of the kernel.  The
length of kernelshape determines the dimensionality of the resulting
kernel</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns :</th><td class="field-body"><p class="first last"><strong>An N-dimensional float array</strong> :</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="AG_fft_tools.smooth_tools.smooth">
<tt class="descclassname">AG_fft_tools.smooth_tools.</tt><tt class="descname">smooth</tt><big>(</big><em>image</em>, <em>kernelwidth=3</em>, <em>kerneltype='gaussian'</em>, <em>trapslope=None</em>, <em>silent=True</em>, <em>psf_pad=True</em>, <em>interp_nan=False</em>, <em>nwidths='max'</em>, <em>min_nwidths=6</em>, <em>return_kernel=False</em>, <em>normalize_kernel=&lt;function sum at 0x10637bcf8&gt;</em>, <em>downsample=False</em>, <em>downsample_factor=None</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/AG_fft_tools/smooth_tools.html#smooth"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#AG_fft_tools.smooth_tools.smooth" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a smoothed image using a gaussian, boxcar, or tophat kernel</p>
<p>Options: 
kernelwidth:</p>
<blockquote>
<div>width of kernel in pixels  (see definitions below)</div></blockquote>
<dl class="docutils">
<dt>kerneltype:</dt>
<dd><p class="first">gaussian, boxcar, or tophat.  
For a gaussian, uses a gaussian with sigma = kernelwidth (in pixels)</p>
<blockquote>
<div>out to [nwidths]-sigma</div></blockquote>
<p class="last">A boxcar is a kernelwidth x kernelwidth square 
A tophat is a flat circle with radius = kernelwidth</p>
</dd>
<dt>Default options:</dt>
<dd><dl class="first last docutils">
<dt>psf_pad: [True]</dt>
<dd>will pad the input image to be the image size + PSF.
Slows things down but removes edge-wrapping effects (see convolve)
This option should be set to false if the edges of your image are
symmetric.</dd>
<dt>interp_nan: [False]</dt>
<dd>Will replace NaN points in an image with the
smoothed average of its neighbors (you can still simply ignore NaN 
values by setting ignore_nan=True but leaving interp_nan=False)</dd>
<dt>silent: [True]</dt>
<dd>turn it off to get verbose statements about kernel types</dd>
<dt>return_kernel: [False]</dt>
<dd>If set to true, will return the kernel as the
second return value</dd>
<dt>nwidths: [&#8216;max&#8217;]</dt>
<dd>number of kernel widths wide to make the kernel.  Set to &#8216;max&#8217; to
match the image shape, otherwise use any integer</dd>
<dt>min_nwidths: [6]</dt>
<dd>minimum number of gaussian widths to make the kernel
(the kernel will be larger than the image if the image size is &lt;
min_widths*kernelsize)</dd>
<dt>normalize_kernel:</dt>
<dd>Should the kernel preserve the map sum (i.e. kernel.sum() = 1)
or the kernel peak (i.e. kernel.max() = 1) ?  Must be a <em>function</em> that can
operate on a numpy array</dd>
<dt>downsample:</dt>
<dd>downsample after smoothing?</dd>
<dt>downsample_factor:</dt>
<dd>if None, default to kernelwidth</dd>
</dl>
</dd>
</dl>
<p>Note that the kernel is forced to be even sized on each axis to assure no
offset when smoothing.</p>
</dd></dl>

</div>
<div class="section" id="module-AG_fft_tools.convolve">
<span id="convolve-module"></span><h2><tt class="xref py py-mod docutils literal"><span class="pre">convolve</span></tt> Module<a class="headerlink" href="#module-AG_fft_tools.convolve" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="AG_fft_tools.convolve.convolve">
<tt class="descclassname">AG_fft_tools.convolve.</tt><tt class="descname">convolve</tt><big>(</big><em>array</em>, <em>kernel</em>, <em>boundary=None</em>, <em>fill_value=0.0</em>, <em>normalize_kernel=False</em><big>)</big><a class="reference internal" href="_modules/AG_fft_tools/convolve.html#convolve"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#AG_fft_tools.convolve.convolve" title="Permalink to this definition">¶</a></dt>
<dd><p>Convolve an array with a kernel</p>
<p>This routine differs from scipy.ndimage.convolve because it includes a
special treatment for NaN values. Rather than including NaNs in the
convolution calculation, which causes large NaN holes in the convolved
image, NaN values are replaced with interpolated values using the kernel
as an interpolation function.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters :</th><td class="field-body"><p class="first"><strong>array: np.ndarray</strong> :</p>
<blockquote>
<div><p>The array to convolve. This should be a 1, 2, or 3-dimensional array
or a list or a set of nested lists representing a 1, 2, or
3-dimensional array.</p>
</div></blockquote>
<p><strong>kernel: np.ndarray</strong> :</p>
<blockquote>
<div><p>The convolution kernel. The number of dimensions should match those
for the array, and the dimensions should be odd in all directions.</p>
</div></blockquote>
<p><strong>boundary: str, optional</strong> :</p>
<blockquote>
<div><dl class="docutils">
<dt>A flag indicating how to handle boundaries:</dt>
<dd><ul class="first last">
<li><dl class="first docutils">
<dt>None <span class="classifier-delimiter">:</span> <span class="classifier">set the <tt class="docutils literal"><span class="pre">result</span></tt> values to zero where the kernel</span></dt>
<dd><p class="first last">extends beyond the edge of the array (default)</p>
</dd>
</dl>
</li>
<li><p class="first">&#8216;fill&#8217; : set values outside the array boundary to fill_value</p>
</li>
<li><p class="first">&#8216;wrap&#8217; : periodic boundary</p>
</li>
<li><dl class="first docutils">
<dt>&#8216;extend&#8217; <span class="classifier-delimiter">:</span> <span class="classifier">set values outside the array to the nearest array</span></dt>
<dd><p class="first last">value</p>
</dd>
</dl>
</li>
</ul>
</dd>
</dl>
</div></blockquote>
<p><strong>fill_value: float, optional</strong> :</p>
<blockquote>
<div><p>The value to use outside the array when using boundary=&#8217;fill&#8217;</p>
</div></blockquote>
<p><strong>normalize_kernel: bool, optional</strong> :</p>
<blockquote>
<div><p>Whether to normalize the kernel prior to convolving</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns :</th><td class="field-body"><p class="first"><strong>result, np.ndarray</strong> :</p>
<blockquote class="last">
<div><p>An array with the same dimensions and type as the input array,
convolved with kernel.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Notes</p>
<p>Masked arrays are not supported at this time.</p>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
        </div>
        <div class="sidebar">
          <h3>Table Of Contents</h3>
          <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="agpy.html">Adam Ginsburg&#8217;s Python Code (agpy)</a></li>
<li class="toctree-l1"><a class="reference internal" href="image_tools.html">Image Tools</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="">AG_fft_tools Package</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#id1"><tt class="docutils literal"><span class="pre">AG_fft_tools</span></tt> Package</a></li>
<li class="toctree-l2"><a class="reference internal" href="#convolve-nd-module"><tt class="docutils literal"><span class="pre">convolve_nd</span></tt> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-AG_fft_tools.correlate2d"><tt class="docutils literal"><span class="pre">correlate2d</span></tt> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-AG_fft_tools.psds"><tt class="docutils literal"><span class="pre">psds</span></tt> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="#smooth-tools-module"><tt class="docutils literal"><span class="pre">smooth_tools</span></tt> Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-AG_fft_tools.convolve"><tt class="docutils literal"><span class="pre">convolve</span></tt> Module</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="plfit.html">plfit Package</a></li>
</ul>

          <h3 style="margin-top: 1.5em;">Search</h3>
          <form class="search" action="search.html" method="get">
            <input type="text" name="q" />
            <input type="submit" value="Go" />
            <input type="hidden" name="check_keywords" value="yes" />
            <input type="hidden" name="area" value="default" />
          </form>
          <p class="searchtip" style="font-size: 90%">
            Enter search terms or a module, class or function name.
          </p>
        </div>
        <div class="clearer"></div>
      </div>
    </div>

    <div class="footer">
      &copy; Copyright 2011, Adam Ginsburg.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.2pre.
    <script type="text/javascript">

      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-6253248-2']);
      _gaq.push(['_trackPageview']);

      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();

    </script>
        
    </div>
  </body>
</html>